<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<jsp:useBean id="member" class="com.kamikaze.Member" scope="session" />
<%	
	session.setAttribute("login", "login.jsp");
	String f = request.getParameter("f");
	if (f == null) {
		if (member.getU_level() == 1) {
			session.setAttribute("main", "news.jsp");
		} else {
			session.setAttribute("main", "news2.jsp");
		}
	} else {
		int func = 0;
		try {
			func = Integer.parseInt(f);
		} catch (NumberFormatException e) {
			// 		e.printStackTrace();
		}

		switch (func) {
		case 1:
			session.setAttribute("main", "clock.jsp");
			break;
		case 2:
			session.setAttribute("main", "regist.jsp");
			break;
		case 3:
			session.setAttribute("main", "shift.jsp");
			break;
		case 4:
			session.setAttribute("main", "attendance.jsp");
			break;
		case 5:
			session.setAttribute("main", "leave.jsp");
			break;
		case 6:
			session.setAttribute("main", "overtime.jsp");
			break;
		case 7:
			session.setAttribute("main", "view.jsp");
			break;
		case 8:
			session.setAttribute("main", "unlock.jsp");
			break;
		case 9:
			session.setAttribute("main", "login.jsp");
			break;
		case 10:
			session.setAttribute("main", "logout.jsp");
			break;
		case 11:	
			session.setAttribute("main", "modification.jsp");
			break;
		case 12:	
			session.setAttribute("main", "dept_shift.jsp");
			break;
		case 13:
			session.setAttribute("main", "leave_check_and_edit.jsp");
			break;
		case 14:
			session.setAttribute("main", "overtime_check_and_edit.jsp");
			break;	
		case 15:
			session.setAttribute("main", "newsalary.jsp");
			break;
		case 16:
			session.setAttribute("main", "overtime_edit.jsp");
			break;
		case 17:
			session.setAttribute("main", "leave_edit.jsp");
			break;		
			
		}
	}
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[]>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
	xml:lang="en">
<head>
<!--
    Created by Artisteer v3.1.0.48375
    Base template (without user's data) checked by http://validator.w3.org : "This page is valid XHTML 1.0 Transitional"
    -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>員工自助系統</title>
<script src="script.js" type="text/javascript"></script>
<script src="jquery-1.8.1.js" type="text/javascript"></script>
<script src="jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
<script src="jquery.timePicker.js" type="text/javascript"></script>
<link rel="stylesheet" href="jquery-ui-1.8.23.custom.css" type="text/css" media="screen" />
<link rel="stylesheet" href="timePicker.css" type="text/css" media="screen" />
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<script>
	$(function() {
		$( ".datepicker" ).datepicker({ dateFormat: "yy-mm-dd" });
		$("#time3, #time4").timePicker();
			var oldTime = $.timePicker("#time3").getTime();
			$("#time3").change(function() {
			if ($("#time4").val()) {
				var duration = ($.timePicker("#time4").getTime() - oldTime);
				var time = $.timePicker("#time3").getTime();
				$.timePicker("#time4").setTime(new Date(new Date(time.getTime() + duration)));
				oldTime = time;
			}
		});
		$("#time4").change(function() {
			if($.timePicker("#time3").getTime() > $.timePicker(this).getTime()) {
				$(this).addClass("error");
			} else {
				$(this).removeClass("error");
			}
		});
	});
</script>
</head>
<body>

<c:if test="${member.user_id != null }">
	<sql:query var="rss" dataSource="jdbc/j2db">
		select * from users, depts where users.dept_number = depts.dept_number and user_id = ?
		<sql:param>${member.user_id }</sql:param>
	</sql:query>
	<c:forEach var="rr" items="${rss.rows }">
		<c:set var="user_level" value="${rr.user_level }" scope="session" />
		<c:set var="dept_number" value="${rr.dept_number }" scope="session" />
		<c:set var="dept_name" value="${rr.dept_name }" scope="session" />
	</c:forEach>
</c:if>

	<div id="art-main">
		<div class="cleared reset-box"></div>
		<div class="art-header">
			<div class="art-header-position">
				<div class="art-header-wrapper">
					<div class="cleared reset-box"></div>
					<div class="art-header-inner">
						<div class="art-headerobject"></div>
						<div class="art-logo">
							<h1 class="art-logo-name">
								<a href="#">LokiT Technology Inc.</a>
							</h1>
							<h2 class="art-logo-text">Employee self-service System</h2>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="cleared reset-box"></div>
		<div id="main">
		<%
		if (!member.login()) {
			//System.out.println(member.login());
			%>
			<jsp:include page="login.jsp" />
			<%
		} else {
		%>
		<div class="art-bar art-nav">
			<div class="art-nav-outer">
				<div class="art-nav-wrapper">
					<div class="art-nav-inner">
						<ul class="art-hmenu">
							<li><a href="index.jsp" class="active">首頁</a></li>
							<li><a href="index.jsp?f=1">網頁打卡</a></li>
							<li><a href="index.jsp?f=12">查詢部門班表</a></li>
							<li><a href="index.jsp?f=4">查詢出缺勤</a></li>
							<li><a href="index.jsp?f=5">提出請假</a></li>
							<li><a href="index.jsp?f=6">申請加班</a></li>							
							<li><a href="index.jsp?f=15">查詢薪資</a></li>
							<li><a href="index.jsp?f=11">修改個人資料</a></li>
							<c:choose>
							<c:when test="${sessionScope.user_level==1}">
							<li><a href="#" class="active">主管專用功能</a>
								<ul>
									<li><a href="#">員工申請核可</a>
										<ul>
											<li><a href="index.jsp?f=13">請假核准或修改</a></li>
											<li><a href="index.jsp?f=14">加班核准或修改</a></li>
										</ul></li>
									<li><a href="#">修改員工資料</a>
										<ul>
											<li><a href="index.jsp?f=7">修改查詢員工資料</a></li>
											<li><a href="index.jsp?f=2">新增員工資料</a></li>
										</ul></li>
									<li><a href="index.jsp?f=3">查詢所有人班表</a></li>
									<li><a href="index.jsp?f=4">查詢所有人出缺勤</a></li>
									<li><a href="index.jsp?f=8">帳號解鎖</a></li>
								</ul>
							</li>
							<li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li>
							<li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li>
							<li><a href="index.jsp?f=10" class="active">登出</a></li>
							</c:when>
							<c:otherwise>
							<li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li>
							<li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li>
							<li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li>
							<li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li>
							<li><a href="index.jsp?f=10" class="active">登出</a></li>
							</c:otherwise>
							</c:choose>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<div class="cleared reset-box"></div>
		<div class="art-box art-sheet">
			<div class="art-box-body art-sheet-body">
				<div class="art-layout-wrapper">
					<div class="art-content-layout">
						<div class="art-content-layout-row">
							<div class="art-layout-cell art-content">
								<div class="art-box art-post">
									<div class="art-box-body art-post-body">
										<div class="art-post-inner art-article">
											<jsp:include page="${main }" >
											<jsp:param value="${param.p }" name="p"/>
											<jsp:param value="${param.user_id }" name="user_id"/>
											<jsp:param value="${param.user_level}" name="user_level"/>
											<jsp:param value="${param.date_begin }" name="date_begin"/>
											<jsp:param value="${param.date_end }" name="date_end"/>
											<jsp:param value="${param.rightnow }" name="rightnow"/>
											<jsp:param value="${param.id }" name="id"/>
											</jsp:include>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		</div>
		<%
		}
		%>
		<div class="art-footer">
			<div class="art-footer-body">
				<div class="art-footer-center">
					<div class="art-footer-wrapper">
						<div class="art-footer-text">
							<p>
								<a href="#">Site map</a> | <a href="#">About us</a> | <a href="#">Contact us</a>
							</p>
							<p>Copyright &#169; 2012. All Rights Reserved.</p>
							<div class="cleared"></div>
							<p class="art-page-footer">
								<a href="http://www.artisteer.com/?p=blogger_templates"
									target="_blank">Blogger Template</a> created with Artisteer.
									Powered by Loki Tao.
							</p>
						</div>
					</div>
				</div>
				<div class="cleared"></div>
			</div>
		</div>
		<div class="cleared"></div>
	</div>
</body>
</html>